package info.motteke.swt;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.TextLayout;

public class ImageReplaceEntry extends ReplaceEntry {

    private final Image image;

    public ImageReplaceEntry(TextLayout layout, Point margin, int offset, Image image) {
        super(layout, margin, offset);
        this.image = image;
    }

    @Override
    protected void draw(GC gc) {
        Point p = getDrawLocation();
        gc.drawImage(image, p.x, p.y);
    }

    @Override
    protected void dispose() {
        image.dispose();
    }
}
